home *** CD-ROM | disk | FTP | other *** search
- //=============================================================================
- //
- // Copyright (C) 1995 by Paul S. McCarthy and Eric Sunshine.
- // Written by Paul S. McCarthy and Eric Sunshine.
- // All Rights Reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the authors
- // and its use is governed by the MiscKit license, found in the file
- // "License.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
- //=============================================================================
- //-----------------------------------------------------------------------------
- // MiscListTracker.M
- //
- // List-mode selection tracking.
- //
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // $Id: MiscListTracker.M,v 1.1 95/09/27 12:21:21 zarnuk Exp $
- // $Log: MiscListTracker.M,v $
- // Revision 1.1 95/09/27 12:21:21 zarnuk
- // Initial revision
- //
- //-----------------------------------------------------------------------------
- #import "MiscListTracker.h"
- #import "MiscSparseSet.h"
- #import "MiscTableBorder.h"
-
-
- @implementation MiscListTracker
-
- //-----------------------------------------------------------------------------
- // setAnchor:
- //-----------------------------------------------------------------------------
- - (void) setAnchor: (MiscCoord_V) pos
- {
- anchor = pos;
- set->setCursor( pos );
- }
-
-
- //-----------------------------------------------------------------------------
- // mouseDown:atPos:
- //-----------------------------------------------------------------------------
- - (void) mouseDown: (NXEvent const*) event atPos: (MiscCoord_V) pos
- {
- if (event->flags & NX_ALTERNATEMASK)
- {
- int cursor = set->getCursor();
- if (cursor < 0 || cursor >= border->count())
- cursor = 0;
- set->add( cursor, pos );
- anchor = cursor;
- set->setCursor( pos );
- }
- else if (event->flags & NX_SHIFTMASK)
- {
- set->toggle( pos );
- [self setAnchor: pos];
- }
- else
- {
- set->empty();
- set->add( pos );
- [self setAnchor: pos];
- }
- }
-
-
- //-----------------------------------------------------------------------------
- // mouseDragged:atPos:
- //-----------------------------------------------------------------------------
- - (void) mouseDragged: (NXEvent const*) event atPos: (MiscCoord_V) pos
- {
- if (pos < 0) pos = 0;
- if (pos >= border->count()) pos = border->count() - 1;
-
- int cursor = set->getCursor();
- if (pos != cursor)
- {
- set->remove( anchor, cursor );
- set->add( anchor, pos );
- set->setCursor( pos );
- }
- }
-
-
- //-----------------------------------------------------------------------------
- // mouseUp:atPos:
- //-----------------------------------------------------------------------------
- - (void) mouseUp: (NXEvent const*) event atPos: (MiscCoord_V) pos
- {
- }
-
-
- //-----------------------------------------------------------------------------
- // keyDown:atPos:
- //-----------------------------------------------------------------------------
- - (void) keyDown: (NXEvent const*) event atPos: (MiscCoord_V) pos
- {
- set->toggle( pos );
- [self setAnchor: pos];
- }
-
- @end
-